//
//  NoneArtistCell.m
//  jingdongfang
//
//  Created by MTiMac02 on 2018/5/9.
//  Copyright © 2018年 BOE-SBG-CTO. All rights reserved.
//

#import "NoneArtistCell.h"
#import "MyFocusMemberModel.h"
@interface NoneArtistCell()
{
     void(^blocks)(MyFocusMemberModel *info);
}
@property (strong, nonatomic) IBOutlet UIImageView *artistImage;
@property (strong, nonatomic) IBOutlet UILabel *artistName;
@property (strong, nonatomic) IBOutlet UIButton *attentArtist;
@end
@implementation NoneArtistCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.artistImage.contentMode = UIViewContentModeScaleAspectFill;
    self.artistImage.layer.borderWidth = 1;
    self.artistImage.layer.borderColor = [UIColor whiteColor].CGColor;
    self.artistImage.layer.cornerRadius=_artistImage.width/2;
    [self.artistImage setClipsToBounds:YES];
    
    self.attentArtist.clipsToBounds=YES;
    self.attentArtist.layer.borderWidth=1.0f;
    self.attentArtist.layer.cornerRadius=15.f;
    self.attentArtist.layer.borderColor=[UIColor c1Color].CGColor;
    self.attentArtist.contentEdgeInsets=UIEdgeInsetsMake(5, 10, 5, 10);
    self.attentArtist.titleLabel.font=[UIFont font14];
    [self.attentArtist setTitleColor:[UIColor c5Color] forState:UIControlStateSelected];
    [self.attentArtist setTitleColor:[UIColor c1Color] forState:UIControlStateNormal];
    [self.attentArtist setTitle:@"已关注" forState:UIControlStateSelected];
    [self.attentArtist setTitle:@"+ 关注" forState:UIControlStateNormal];
    [self.attentArtist addTarget:self action:@selector(attentBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.attentArtist setSelected:NO];
}
-(void)layoutSubviews{
    MyFocusMemberModel *recArtistInfo=self.data;
    [self.artistImage sd_setImageWithURL:[NSURL URLWithString:recArtistInfo.image]];
    self.artistName.text=recArtistInfo.nike;
    if ([recArtistInfo.attentionState integerValue]==0) {//是否 关注  0=已关注，1=未关注
        self.attentArtist.layer.borderColor = [UIColor c5Color].CGColor;
        self.attentArtist.selected=YES;
    }else{
        self.attentArtist.layer.borderColor = [UIColor c1Color].CGColor;
        self.attentArtist.selected=NO;
    }
    
}
-(void)attentBtnClick:(UIButton *)attBtn{
    self.attentArtist.selected=!self.attentArtist.isSelected;
    if ([self.attentArtist isSelected]) {
        self.attentArtist.layer.borderColor=[UIColor c5Color].CGColor;
    }else{
        self.attentArtist.layer.borderColor=[UIColor c1Color].CGColor;
    }
    if (blocks)
    {
        blocks((MyFocusMemberModel *)self.data);
    }
}
-(void)followOwerAction:(void (^)(MyFocusMemberModel *))block{
    blocks = [block copy];
}

@end
